﻿using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Net.Mail;

namespace TimeCapsule
{
	public partial class Introduce : System.Web.UI.Page
	{
		protected static int idx = 0;
		protected void Page_Load(object sender, EventArgs e)
		{
			Bind();			
			System.Diagnostics.Debug.WriteLine(Util.generateKey(20));
		}

		private void Bind()
		{
			dbAccess da = new dbAccess();
			PagedDataSource pds = new PagedDataSource();
			if(idx>10)
				idx = 0;
			pds = da.BindBlog(idx++);
			//pds = da.BindBlogReply(idx++, 10);
			pds.CurrentPageIndex = 0;

			dl.DataSource = pds;
			dl.DataBind();
		}
	
		protected void Click(object sender, EventArgs e)
		{
			Bind();
		}
	
		protected void itemCommand(object sender, RepeaterCommandEventArgs e)
		{
			switch (e.CommandName.ToString())
			{
				case "WriteReply":
					WriteReply(e.Item);
					break;
				default:
					return;
			}
		}
		
		protected void WriteReply(RepeaterItem item)
		{
			System.Diagnostics.Debug.WriteLine("WriteReply");
		}
	
		protected void Unnamed1_Click(object sender, EventArgs e)
		{
			MailMessage mail = new MailMessage();
			mail.To.Add("ekagud@mirageworks.co.kr");
			mail.From = new MailAddress("ekagud@gmail.com");
			mail.Subject = "SUBJECT";
			mail.Body = "BODY";

			mail.IsBodyHtml = true;

			SmtpClient smtp = new SmtpClient();
			smtp.Host = "smtp.gmail.com";
			smtp.Credentials = new System.Net.NetworkCredential("ekagud@gmail.com", "ekaguddl");
			smtp.EnableSsl = true;
			smtp.Send(mail);
		}
}

}
